/* name: test
 * author: 5ab
 * created at: 2024-07-01
 */
#include <iostream>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define ssz(x) (int((x).size()))

auto chmax = [](auto& x, auto y) { if (x < y) x = y; };
auto chmin = [](auto& x, auto y) { if (y < x) x = y; };

using ll = long long;
const int L = 1024;

int c[L];
int m, l;

void dfs(int n, int cx, int lx)
{
	if (n == 0)
	{
		c[cx % l]++;
		return;
	}
	for (int i = 0; i < l; i++)
		dfs(n - 1, cx ^ (i * lx), i);
}

void fwt(int *c, int op)
{
	ll x, y;
	for (int i = 0, jp = 2, kp = 1; i < m; i++, jp <<= 1, kp <<= 1)
		for (int j = 0; j < l; j += jp)
			for (int k = 0; k < kp; k++)
			{
				x = c[j+k] + c[j+k+kp];
				y = c[j+k] - c[j+k+kp];
				c[j+k] = x * op, c[j+k+kp] = y * op;
			}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, x;
	
	cin >> n >> m >> x;
	l = 1 << m;
	
	dfs(n, 0, x);
	for (int i = 0; i < l; i++)
		cout << c[i] << " \n"[i == l - 1];
	fwt(c, 1);
	for (int i = 0; i < l; i++)
		cout << c[i] << " \n"[i == l - 1];
	
	// ll ans = 0;
	// for (int i = 0; i < l; i++)
	// 	ans += ll(c[i]) * i;
	// cout << ans << endl;
	
	return 0;
}
// started coding at: 07-01 10:57:24